/**
 * filename:myechars.js
 * @author liudm 
 */
//运行趋势图相关函数
//运行趋势图相关函数
function UpdateRunLineChar(myChart1,myChart2,myChart3,myChart4,sn)
{
	var surl = "getOneDayDevStatus?devsn="+sn;
	$.ajax({
        type: "post",
        global:false,
        //async:false, 
        contentType: "application/json",
        dataType: "json",
        timeout: 1500, //超时时间设置，单位毫秒
        url: surl,
        data: {},
        success: function(data) {
            if (data.success) 
            {
            	DrawInTdsChart(myChart1,data);
            	DrawOutTdsChart(myChart2,data);
            	DrawFlowChart(myChart3,data);
            	DrawOutPresureChart(myChart4,data);
            }
            else
            {
            	alertMsg.error(data.msg);
            }
        },
        complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
            if (status == 'timeout') { //超时,status还有success,error等值的情况
                //ajaxTimeoutTest.abort();　　　　　
                //alert("超时");　　　　
            }　　
        },
        error: function(textStatus, errorThrown) {
            //alert(XMLHttpRequest.status + "<br>" + XMLHttpRequest.readyState + "<br>" + "<br>" + textStatus);
        	//ajaxTimeoutTest.abort();
        	//alert(XMLHttpRequest.status);
        }
    });
	
}
function DrawInTdsChart(chart,data)
{
	var	option = {
		    title : {
		        text: '供水导电率趋势图',
		        subtext: '24小时曲线'
		    },
		    tooltip : {
		        trigger: 'axis'
		    },
		    color:['blue'],
		    legend: {
		        data:['']
		    },
		    toolbox: {
		        show : true,
		        feature : {
		            mark : {show: false},
		            dataView : {show: false, readOnly: false},
		            magicType : {show: false, type: ['line']},
		            restore : {show: false},
		            saveAsImage : {show: false}
		        }
		    },
		    calculable : false,
		    xAxis : [
		        {
		            type : 'category',
		            boundaryGap : false,
		            data : data.dateTimeList//['2018-03-06 09:52:46','2018-03-06 09:51:46','2018-03-06 09:50:46','2018-03-06 09:49:46','2018-03-06 09:41:46','2018-03-06 09:39:46','2018-03-06 09:35:40','2018-03-06 09:33:40','2018-03-06 09:32:40','2018-03-06 09:31:40','2018-03-06 09:30:40','2018-03-06 09:29:40','2018-03-05 16:36:13','2018-03-05 16:34:13','2018-03-05 16:33:13','2018-03-05 16:32:13','2018-03-05 16:31:13','2018-03-05 16:30:13','2018-03-04 17:56:10','2018-03-04 17:55:10','2018-03-04 17:54:10','2018-03-04 17:53:10','2018-03-04 17:52:10','2018-03-04 17:51:10','2018-03-03 22:47:48','2018-03-03 22:46:48','2018-03-03 22:44:48','2018-03-03 22:43:48','2018-03-03 22:41:49','2018-03-03 11:24:46','2018-03-03 11:23:46','2018-03-03 11:22:51','2018-03-03 10:37:23','2018-03-02 16:37:35','2018-03-02 16:36:35','2018-03-02 16:35:35','2018-03-02 16:34:35','2018-03-02 16:33:35','2018-03-02 16:31:35','2018-03-02 08:18:34','2018-03-02 08:17:34','2018-03-02 08:16:34','2018-03-02 08:15:34','2018-03-02 08:13:34','2018-03-02 08:12:34','2018-03-01 10:35:30','2018-03-01 10:34:30','2018-03-01 10:33:30','2018-03-01 10:32:30','2018-03-01 10:31:30','2018-03-01 10:30:30','2018-03-01 10:29:30','2018-03-01 10:28:30','2018-03-01 10:27:35','2018-02-28 11:36:27','2018-02-28 11:35:27','2018-02-28 11:33:27','2018-02-28 11:32:27','2018-02-27 17:04:24','2018-02-27 17:02:24','2018-02-27 17:01:24','2018-02-27 17:00:24','2018-02-27 16:59:24','2018-02-27 16:58:24','2018-02-27 10:32:23','2018-02-27 10:29:23','2018-02-27 10:28:23','2018-02-27 10:27:23','2018-02-27 10:26:23','2018-02-26 19:22:20','2018-02-26 19:21:20','2018-02-26 19:20:20','2018-02-26 19:19:20','2018-02-26 19:18:20','2018-02-26 19:17:20','2018-02-26 19:16:46','2018-02-26 10:16:48','2018-02-26 10:15:48','2018-02-26 10:14:48','2018-02-26 10:13:48','2018-02-26 10:12:48','2018-02-26 10:11:48','2018-02-26 10:11:13','2018-02-25 18:08:45','2018-02-25 18:07:45','2018-02-25 18:06:45','2018-02-25 18:05:45','2018-02-25 18:04:45','2018-02-25 18:03:45','2018-02-24 12:24:15','2018-02-24 12:23:15','2018-02-24 12:22:15','2018-02-24 12:21:15','2018-02-24 12:20:15','2018-02-24 12:19:15','2018-02-23 16:04:12','2018-02-23 16:03:12','2018-02-23 16:02:12','2018-02-23 16:01:12','2018-02-23 16:00:12','2018-02-23 15:59:12','2018-02-23 09:20:11','2018-02-23 09:19:11','2018-02-23 09:17:11','2018-02-23 09:16:11','2018-02-23 09:15:11','2018-02-23 09:14:11','2018-02-23 09:13:11','2018-02-23 09:12:11','2018-02-23 09:11:11','2018-02-23 09:10:11','2018-02-23 09:09:11','2018-02-23 09:08:11','2018-02-23 09:07:11','2018-02-23 09:06:11','2018-02-23 09:05:11','2018-02-23 09:04:11','2018-02-12 06:12:00','2018-02-12 06:11:00','2018-02-12 06:10:00','2018-02-12 06:09:00','2018-02-12 06:08:00','2018-02-12 06:07:00','2018-02-12 06:05:00','2018-02-12 06:04:00','2018-02-12 06:03:00','2018-02-12 06:02:00','2018-02-12 05:59:00','2018-02-12 05:58:00','2018-02-12 05:57:00','2018-02-12 05:56:00','2018-02-12 05:55:00','2018-02-12 05:54:00','2018-02-12 05:53:00','2018-02-12 05:52:00','2018-02-12 05:51:00','2018-02-12 05:50:00','2018-02-12 05:49:00','2018-02-12 05:48:00','2018-02-12 05:47:00','2018-02-12 05:46:00','2018-02-12 05:45:00','2018-02-12 05:42:59','2018-02-12 05:41:59','2018-02-12 05:40:59','2018-02-12 05:39:59','2018-02-12 05:37:59','2018-02-12 05:36:59','2018-02-12 05:35:59','2018-02-12 05:34:59','2018-02-12 05:33:59','2018-02-12 05:32:59','2018-02-12 05:30:59','2018-02-12 05:29:59','2018-02-12 05:28:59','2018-02-12 05:27:59','2018-02-12 05:26:59','2018-02-12 05:25:59','2018-02-12 05:23:59','2018-02-12 05:22:59','2018-02-12 05:21:59','2018-02-12 05:18:59','2018-02-12 05:17:59','2018-02-12 05:16:59','2018-02-12 05:15:59','2018-02-12 05:13:59','2018-02-12 05:12:59','2018-02-12 05:11:59','2018-02-12 05:10:59','2018-02-12 05:09:59','2018-02-12 05:08:59','2018-02-12 05:07:59','2018-02-12 05:06:59','2018-02-12 05:05:59','2018-02-12 05:04:59','2018-02-12 05:03:59','2018-02-12 05:02:59','2018-02-12 05:01:59','2018-02-12 05:00:59','2018-02-12 04:59:59','2018-02-12 04:58:59','2018-02-12 04:57:59','2018-02-12 04:56:59','2018-02-12 04:55:59','2018-02-12 04:54:59','2018-02-12 04:53:59','2018-02-12 04:52:59','2018-02-12 04:51:59','2018-02-12 04:50:59','2018-02-12 04:49:59','2018-02-12 04:48:59','2018-02-12 04:47:59','2018-02-12 04:46:59','2018-02-12 04:45:59','2018-02-12 04:44:59','2018-02-12 04:43:59','2018-02-12 04:42:59','2018-02-12 04:39:59','2018-02-12 04:37:59','2018-02-12 04:36:59','2018-02-12 04:35:59','2018-02-12 04:34:59','2018-02-12 04:33:59','2018-02-12 04:32:59','2018-02-12 04:31:59','2018-02-12 04:30:59','2018-02-12 04:28:59','2018-02-12 04:27:59','2018-02-12 04:26:59','2018-02-12 04:25:59','2018-02-12 04:24:59','2018-02-12 04:23:59','2018-02-12 04:22:59','2018-02-12 04:21:59','2018-02-12 04:20:59','2018-02-12 04:18:59','2018-02-12 04:17:59','2018-02-12 04:16:59','2018-02-12 04:15:59','2018-02-12 04:14:59','2018-02-12 04:13:59','2018-02-12 04:11:59','2018-02-12 04:10:59','2018-02-12 04:09:59','2018-02-12 04:08:59','2018-02-12 04:07:59','2018-02-12 04:06:59','2018-02-12 04:05:59','2018-02-12 04:04:59','2018-02-12 04:03:59','2018-02-12 04:02:59','2018-02-12 04:01:59','2018-02-12 04:00:59','2018-02-12 03:59:59','2018-02-12 03:58:59','2018-02-12 03:57:59','2018-02-12 03:56:59','2018-02-12 03:55:59','2018-02-12 03:54:59','2018-02-12 03:53:59','2018-02-12 03:52:59','2018-02-12 03:51:59','2018-02-12 03:50:59','2018-02-12 03:49:59','2018-02-12 03:48:59','2018-02-12 03:46:59','2018-02-12 03:45:59','2018-02-12 03:44:59','2018-02-12 03:43:59','2018-02-12 03:41:59','2018-02-12 03:40:59','2018-02-12 03:39:59','2018-02-12 03:37:59','2018-02-12 03:36:59','2018-02-12 03:34:59','2018-02-12 03:32:59','2018-02-12 03:31:59','2018-02-12 03:30:59','2018-02-12 03:29:59','2018-02-12 03:28:59','2018-02-12 03:27:59','2018-02-12 03:26:59','2018-02-12 03:25:59','2018-02-12 03:24:59','2018-02-12 03:23:59','2018-02-12 03:22:59','2018-02-12 03:21:59','2018-02-12 03:20:59','2018-02-12 03:19:59','2018-02-12 03:17:59','2018-02-12 03:16:59','2018-02-12 03:14:59','2018-02-12 03:13:59','2018-02-12 03:12:59','2018-02-12 03:11:59','2018-02-12 03:10:59','2018-02-12 03:09:59','2018-02-12 03:08:59','2018-02-12 03:07:59','2018-02-12 03:06:59','2018-02-12 03:05:59','2018-02-12 03:04:59','2018-02-12 03:03:59','2018-02-12 03:02:59','2018-02-12 03:01:59','2018-02-12 03:00:59','2018-02-12 02:59:59','2018-02-12 02:58:59']
		        }
		    ],
		    yAxis : [
		        {
		            type : 'value',
		            axisLabel : {
		                formatter: '{value}'
		            }
		        }
		    ],
		    series : [
		        {
		            name:'导电率',
		            type:'line',
		            //data:[50.4,143.6,151.1,135.4,-0.1,51.2,48.8,-0.2,-0.2,-0.2,-0.2,-0.2,-0.1,-0.1,-0.1,-0.1,0,64.1,50.1,-0.1,-0.1,-0.1,-0.1,-0.1,-0.1,-0.1,-0.1,-0.1,59.6,-0.1,-0.1,62.6,62.5,32.3,-0.1,-0.1,-0.1,-0.1,64.1,-0.2,-0.2,-0.1,-0.2,-0.1,-0.1,33.1,49,-0.1,-0.1,-0.1,-0.1,-0.1,-0.1,63.7,-0.1,-0.1,-0.1,-0.1,-0.1,-0.1,0,-0.1,0,59.3,44,-0.1,-0.1,-0.1,0,-0.1,-0.1,-0.1,-0.1,-0.1,60.3,61.2,-0.1,-0.1,-0.1,-0.1,-0.1,66.8,66.7,62.8,-0.1,-0.1,-0.1,-0.1,-0.1,-0.1,-0.1,-0.1,-0.1,-0.1,-0.1,0,-0.1,0,0,0,0,66.6,-0.1,-0.1,-0.2,-0.1,8.2,43.1,41.5,38.3,30.3,47.8,53.6,49,60.6,212.1,80.6,49.5,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2,212.2],
		            data:data.inTdsList,
		            lineStyle: {
	                        normal: {
	                            color: 'blue'
	                        }
	                    },
		            markPoint : {
		                data : [
		                    {type : 'max', name: '最大值'},
		                    {type : 'min', name: '最小值'}
		                ]
		            },
		            markLine : {
		                data : [
		                    {type : 'average', name: '平均值'}
		                ]
		            }
		        }
		    ]
		};
	chart.setOption(option);
}

function DrawOutTdsChart(chart,data)
{
	var	option = {
		    title : {
		        text: '产水导电率趋势图',
		        subtext: '24小时曲线'
		    },
		    tooltip : {
		        trigger: 'axis'
		    },
		    color:['blue'],
		    legend: {
		        data:['']
		    },
		    toolbox: {
		        show : true,
		        feature : {
		            mark : {show: false},
		            dataView : {show: false, readOnly: false},
		            magicType : {show: false, type: ['line']},
		            restore : {show: false},
		            saveAsImage : {show: false}
		        }
		    },
		    calculable : false,
		    xAxis : [
		        {
		            type : 'category',
		            boundaryGap : false,
		            data : data.dateTimeList
		        }
		    ],
		    yAxis : [
		        {
		            type : 'value',
		            axisLabel : {
		                formatter: '{value}'
		            }
		        }
		    ],
		    series : [
		        {
		            name:'导电率',
		            type:'line',
		            data:data.outTdsList,
		            lineStyle: {
	                        normal: {
	                            color: 'blue'
	                        }
	                    },
		            markPoint : {
		                data : [
		                    {type : 'max', name: '最大值'},
		                    {type : 'min', name: '最小值'}
		                ]
		            },
		            markLine : {
		                data : [
		                    {type : 'average', name: '平均值'}
		                ]
		            }
		        }
		    ]
		};
	chart.setOption(option);
}

function DrawFlowChart(chart,data)
{
	var	option = {
		    title : {
		        text: '供/产水流量趋势图',
		        subtext: '24小时曲线'
		    },
		    tooltip : {
		        trigger: 'axis'
		    },
		    color:['blue','green'],
		    legend: {
		        data:['供水流量','产水流量']
		    },
		    toolbox: {
		        show : true,
		        feature : {
		            mark : {show: false},
		            dataView : {show: false, readOnly: false},
		            magicType : {show: false, type: ['line']},
		            restore : {show: false},
		            saveAsImage : {show: false}
		        }
		    },
		    calculable : false,
		    xAxis : [
		        {
		            type : 'category',
		            boundaryGap : false,
		            data : data.inFlowDateTimeList
		        }
		    ],
		    yAxis : [
		        {
		            type : 'value',
		            axisLabel : {
		                formatter: '{value}'
		            }
		        }
		    ],
		    series : [
		        {
		            name:'供水流量',
		            type:'line',
		            data:data.inFlowList,
		            lineStyle: {
	                        normal: {
	                            color: 'blue'
	                        }
	                    },
		            markPoint : {
		                data : [
		                    {type : 'max', name: '最大值'},
		                    {type : 'min', name: '最小值'}
		                ]
		            },
		            markLine : {
		                data : [
		                    {type : 'average', name: '平均值'}
		                ]
		            }
		        },
		        {
		            name:'产水流量',
		            type:'line',
		            data:data.outFlowList,
		            lineStyle: {
	                        normal: {
	                            color: 'green'
	                        }
	                    },
		            markPoint : {
		                data : [
		                    {type : 'max', name: '最大值'},
		                    {type : 'min', name: '最小值'}
		                ]
		            },
		            markLine : {
		                data : [
		                    {type : 'average', name: '平均值'}
		                ]
		            }
		        }
		    ]
		};
	chart.setOption(option);
}

function DrawOutPresureChart(chart,data)
{	
	var	option = {
		    title : {
		        text: '供水压力',
		        subtext: '24小时曲线'
		    },
		    tooltip : {
		        trigger: 'axis'
		    },
		    color:['blue'],
		    legend: {
		        data:['']
		    },
		    toolbox: {
		        show : true,
		        feature : {
		            mark : {show: false},
		            dataView : {show: false, readOnly: false},
		            magicType : {show: false, type: ['line']},
		            restore : {show: false},
		            saveAsImage : {show: false}
		        }
		    },
		    calculable : false,
		    xAxis : [
		        {
		            type : 'category',
		            boundaryGap : false,
		            data : data.dateTimeList
		        }
		    ],
		    yAxis : [
		        {
		            type : 'value',
		            axisLabel : {
		                formatter: '{value}'
		            }
		        }
		    ],
		    series : [
		        {
		            name:'压力',
		            type:'line',
		            data:data.outPresureList,
		            lineStyle: {
	                        normal: {
	                            color: 'blue'
	                        }
	                    },
		            markPoint : {
		                data : [
		                    {type : 'max', name: '最大值'},
		                    {type : 'min', name: '最小值'}
		                ]
		            },
		            markLine : {
		                data : [
		                    {type : 'average', name: '平均值'}
		                ]
		            }
		        }
		    ]
		}; 
	chart.setOption(option); 
}